#!/bin/bash

if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi

for i in ods_brand ods_category ods_content ods_product ods_review ods_sku ods_user_profile
do
/opt/module/sqoop/bin/sqoop import --connect jdbc:mysql://node101:3306/jtp_goods_warehouse  \
    --username root  --password 123456 \
    --delete-target-dir \
    -m 1 \
    --table $i \
    --target-dir /warehouse/app_ads/ads/$i/"${data_date}" \
    -z \
    --compression-codec gzip \
    --null-string '\\N' --null-non-string '\\N' \
    --fields-terminated-by '\001'
done